import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.regex.Pattern;



public class ExOnString {
	
	public static void main(String[] args) throws IOException {
/*		//StringBuffer sb = new StringBuffer();
		String str1;
		String str ="hiiiisushiliiiii";
		
		int startIndex = 0;
		int endIndex = 100;
		String email ="FFFFILE Load Successful FOFDB.KZ FILE VERSION DATE & TIME FILE LOADED FFFFILE Load Successful FOFDB.KZ FILE VERSION DATE & TIME FILE LOADED";
		BufferedReader br = null;
		try {
			String emailMsg ="FFFFILE Load Successful FOFDB.KZ FILE VERSION currentTimestamp FILE LOADED DATE & TIME FILE CREATED";
			
			String finalMsg = emailMsg.replaceAll(Pattern.quote("DATE & TIME FILE CREATED"),"DATE & TIME FILE LOADED");
			System.out.println("final Msg "+finalMsg);
			
			if(emailMsg.contains("FOFDB.KZ")){
				System.out.println("trueeeee");
			}
			
			
			//StringBuilder strBuild =new StringBuilder("CLIF-EMEA Load Successful FOFDB.KZ FILE VERSION currentTimestamp FILE LOADED DATE & TIME FILE CREATED");
			
			String strr = "rama";
			String strk = "krishna";
			String strl ="ravi";
			String strd =strr+" "+strk+" "+new Date().toString()+" "+strl;
			System.out.println(strd);
			for(int k =i; k < j; k++){
				sb.append(str.charAt(k));
				
			}
			System.out.println("string valuee"+sb);
			//StringBuffer sb =new StringBuffer();
			//int i = str.length();
			//System.out.println(i);
			if(endIndex > str.length()){
				endIndex = str.length();
			}
			str1 = str.substring(startIndex, endIndex);
			System.out.println(str1);
			
			//SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmm");
			
			Date date = new Date(System.currentTimeMillis());
			Calendar calendar = Calendar.getInstance();
			calendar.setTimeZone(TimeZone.getTimeZone("CET"));
			calendar.setLenient(true);
			calendar.setTime(date);
			System.out.println("cet time"+calendar.getTime());
			//dateFormat.format(date);
			System.out.println("date"+date);
			System.out.println(email.replaceAll(Pattern.quote("DATE & TIME"), String.valueOf(date)));
			if(email.contains("FOFDB.KZ")){
				System.out.println("string exists");
			}
			
			
			
			if(emailMsg.contains("FOFDB.KZ")){
            	String copySanListPath = "C:\\RK\\FOFDB.kz";
            	String modifiedString = null;
            	File sanFile = new File(copySanListPath);
            	br = new BufferedReader(new FileReader(sanFile));
            	String line = br.readLine();
            	if(line != null){
            		String subLine = line.substring(18, 38);
            		modifiedString = emailMsg.replaceAll(Pattern.quote("DATE & TIME"),subLine);//(subLine== null)? "":subLine
            		
            	}
            	String finalString = modifiedString.replaceAll(Pattern.quote("currentTimestamp"), String.valueOf(new Date()));
            	System.out.println("final content"+finalString);
            }
			
			 String subLine = null;
			 StringBuilder sb = null;
	         String modifiedEmailMsg = null;
	         String finalEmailMsg = null;
			if(emailMsg.contains("FOFDB.KZ")){
            	String copySanListPath = "C:\\RK\\fml.rul";
            	File sanFile = new File(copySanListPath);
            	br = new BufferedReader(new FileReader(sanFile));
            	String line = br.readLine();
            	for (int lineNo = 1; lineNo < 5; lineNo++) {
                    if (lineNo == 4) {
                        line = br.readLine();
                        subLine = line.substring(9, line.length());
                   		modifiedEmailMsg = emailMsg.replaceAll(Pattern.quote("DATE & TIME"), (subLine== null)? "":subLine);
                    	finalEmailMsg = modifiedEmailMsg.replaceAll(Pattern.quote("currentTimestamp"), String.valueOf(new Date()));
                    	System.out.println(finalEmailMsg);
                    } else
                          System.out.println(br.readLine());
            	}
            	
            	if(line != null){
            		subLine = line.substring(60, 78);
            		modifiedEmailMsg = emailMsg.replaceAll(Pattern.quote("DATE & TIME"), (subLine== null)? "":subLine);
            	}
            	finalEmailMsg = modifiedEmailMsg.replaceAll(Pattern.quote("currentTimestamp"), String.valueOf(new Date()));
            	System.out.println(finalEmailMsg);
			}
			
			String s ="krishna";
			System.out.println((s ==null)?"rama":"krishna");
			
			StringBuilder strBuild = new StringBuilder("ramakrishna");
			StringBuffer strBuff = new StringBuffer("ramakrishna");
			strBuild.append("rama").reverse().replace(0, 3, "ra");
			strBuff.append("rama").reverse().replace(0, 3, "ra");
			System.out.println("stringbuilder"+strBuild);
			System.out.println("stringbuffer"+strBuff);*/
			
			
			
		/*}catch (StringIndexOutOfBoundsException e) {
			int i = str.trim().length();
			str1 =str.substring(0, str.trim().length());
			System.out.println(e.getMessage());
			System.out.println("substring"+"\n"+str1);
			System.out.println("index value of string"+i);
			e.printStackTrace();
		}*/
		
		
		
		
		
		
		///employee e = new employee(1, "rama");
		//employee e1 = new employee(1, "rama");
		//String a=new String("b");
		//String b=new String("b");
		
		//System.out.println(e.hashCode());
		//System.out.println(e1.hashCode());
		//System.out.println(e.equals(e1));
		
		
		
		
		
		
		
		
		
		
		
		
		
	}

}
/*class employee {
	
	
	private String eName;
	private int eNo;
	public employee(int eNo, String eName) {
		this.eNo = eNo;
		this.eName = eName;
		System.out.println("employee"+eNo+"\t"+eName);
	}
	public boolean equals(Object obj)
			{
				if(this == obj)
					return true;
				if((obj == null) || (obj.getClass() != this.getClass()))
					return false;
				// object must be Test at this point
				employee test = (employee)obj;
				return eNo == test.eNo &&
				(eName == test.eName || (eName != null && eName.equals(test.eName)));
			}
	
			public int hashCode()
			{
				int hash = 7;
				hash = 31 * hash + eNo;
				hash = 31 * hash + (null == eName ? 0 : eName.hashCode());
				return hash;
			}
	
}*/